using ASP;
using HoWave.Alipay;
using HoWave.Web;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
public class notify_url_OrderPay : Page, IRequiresSessionState
{
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		SortedDictionary<string, string> requestPost = this.GetRequestPost();
		if (requestPost.Count > 0)
		{
			Notify notify = new Notify();
			bool flag = notify.Verify(requestPost, base.Request.Form["notify_id"], base.Request.Form["sign"]);
			if (flag)
			{
				string text = base.Request.Form["trade_no"];
				string paymentNum = base.Request.Form["out_trade_no"];
				string text2 = base.Request.Form["total_fee"];
				string text3 = base.Request.Form["subject"];
				string text4 = base.Request.Form["body"];
				string text5 = base.Request.Form["buyer_email"];
				string text6 = base.Request.Form["trade_status"];
				OrderAction orderAction = new OrderAction();
				if (base.Request.Form["trade_status"] == "TRADE_FINISHED")
				{
					orderAction.PayReturn(paymentNum, "Pay");
				}
				else
				{
					if (base.Request.Form["trade_status"] == "TRADE_SUCCESS")
					{
						orderAction.PayReturn(paymentNum, "Pay");
					}
				}
				base.Response.Write("success");
			}
			else
			{
				base.Response.Write("fail");
			}
		}
		else
		{
			base.Response.Write("无通知参数");
		}
	}
	public SortedDictionary<string, string> GetRequestPost()
	{
		SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
		NameValueCollection form = base.Request.Form;
		string[] allKeys = form.AllKeys;
		for (int i = 0; i < allKeys.Length; i++)
		{
			sortedDictionary.Add(allKeys[i], base.Request.Form[allKeys[i]]);
		}
		return sortedDictionary;
	}
}
